home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / UNIQ.C < prev    next >
C/C++ Source or Header  |  1991-04-11  |  1KB  |  42 lines

  1. /* Copyright (C) 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* uniq.c */
  21. /* A cheap MS-DOS substitute for just enough of the Unix uniq utility. */
  22. #include <stdio.h>
  23. #include <string.h>
  24.  
  25. /* Usage:
  26.     uniq
  27.  * Reads from stdin, writes to stdout, eliminating any line that is
  28.  * equal to the previous line.
  29.  */
  30.  
  31. main(int argc, char *argv[])
  32. {    char x[200], y[200];
  33.     char *a = x, *b = y, *t;
  34.     b[0] = 0;
  35.     while ( (*a = 0), gets(a), !feof(stdin) )
  36.        {    if ( strcmp(a, b) ) puts(a);
  37.         t = a, a = b, b = t;
  38.        }
  39.     if ( *a && strcmp(a, b) ) puts(a);
  40.     return 0;
  41. }
  42.